package com.gd.iot.energy.controller.dailymanage;

import com.gd.iot.energy.annotation.SystemLogRecordMonitor;
import com.gd.iot.energy.consts.SystemConsts;
import com.gd.iot.energy.entity.ResponseEntity;
import com.gd.iot.energy.pojo.common.vo.PageVO;
import com.gd.iot.energy.pojo.dailymanage.vo.ChargeBookPageVO;
import com.gd.iot.energy.pojo.dailymanage.vo.ChargeQueryPageVO;
import com.gd.iot.energy.pojo.dailymanage.vo.ChargeStatisticsPageVO;
import com.gd.iot.energy.service.dailymanage.OperationfeeChargeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 日常管理-财务管理-收费统计/收费查询/退费查询/收费台账
 *
 * @author kris
 * @date Created at 2020/8/7 10:50
 */
@Api(value = "日常管理-财务管理-收费统计/收费查询/退费查询/收费台账",tags = "日常管理-财务管理-收费统计/收费查询/退费查询/收费台账")
@RestController
@RequestMapping("/admin/finance")
public class FinanceController {

    @Autowired
    private OperationfeeChargeService operationfeeChargeService;

    @ApiOperation("收费统计分页列表")
    @SystemLogRecordMonitor("收费统计分页列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "operatorId", value = "操作员", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "cycle", value = "统计周期（0日，1月，2季，3年）", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "date", value = "选择日期", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "payway", value = "支付方式（CASH，0，现金),(WEIXIN, 1, 微信)，(ALIPAY, 2, 支付宝)，(SYSTEM, 3, 系统)", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "paychannel", value = "收费渠道 (WUYE, 0, 物业),(APP, 1, 移动终端),(PLATFORM, 2, 费用核算)", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "areaId", value = "所属区域", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderColumn", value = "排序字段", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderType", value = "排序类型(asc,desc)", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/getChargeStatisticsPageVO")
    public ResponseEntity<PageVO<ChargeStatisticsPageVO>> getChargeStatisticsPageVO(
            @RequestParam(value = "operatorId",required = false)Integer operatorId,
            @RequestParam(value = "cycle",required = false)String cycle,
            @RequestParam(value = "date",required = false)String date,
            @RequestParam(value = "payway",required = false)Integer payway,
            @RequestParam(value = "paychannel",required = false)Integer paychannel,
            @RequestParam(value = "areaId",required = false)Integer areaId,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10")Integer pageSize,
            @RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum,
            @RequestParam(value = "orderColumn",required = false,defaultValue = "id") String orderColumn,
            @RequestParam(value = "orderType",required = false,defaultValue = "asc") String orderType
    ) {

        PageVO<ChargeStatisticsPageVO> pageVO = operationfeeChargeService.getChargeStatisticsPageVO(operatorId,cycle,date,
                areaId,payway,paychannel,pageSize,pageNum,orderColumn,orderType);
        return new ResponseEntity<>(pageVO);
    }

    @ApiOperation("收费统计分页列表-excel导出")
    @SystemLogRecordMonitor("收费统计分页列表-excel导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "operatorId", value = "操作员", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "cycle", value = "统计周期（0日，1月，2季，3年）", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "date", value = "选择日期", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "payway", value = "支付方式（CASH，0，现金),(WEIXIN, 1, 微信)，(ALIPAY, 2, 支付宝)，(SYSTEM, 3, 系统)", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "paychannel", value = "收费渠道 (WUYE, 0, 物业),(APP, 1, 移动终端),(PLATFORM, 2, 费用核算)", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "areaId", value = "所属区域", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderColumn", value = "排序字段", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderType", value = "排序类型(asc,desc)", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/exportChargeStatisticsExcel")
    public void exportChargeStatisticsExcel(
            @RequestParam(value = "operatorId",required = false)Integer operatorId,
            @RequestParam(value = "cycle",required = false)String cycle,
            @RequestParam(value = "date",required = false)String date,
            @RequestParam(value = "payway",required = false)Integer payway,
            @RequestParam(value = "paychannel",required = false)Integer paychannel,
            @RequestParam(value = "areaId",required = false)Integer areaId,
            @RequestParam(value = "orderColumn",required = false,defaultValue = "id") String orderColumn,
            @RequestParam(value = "orderType",required = false,defaultValue = "asc") String orderType
    ) {

        operationfeeChargeService.exportChargeStatisticsExce(operatorId,cycle,date,
                areaId,payway,paychannel,orderColumn,orderType);
    }

    @ApiOperation("客户费用记录分页列表-由原来的收费查询/退费查询合并而来")
    @SystemLogRecordMonitor("客户费用记录分页列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "chargeType", value = "费用类型 (缴费, 0),(退费, 1)", dataType = "string", paramType = "query", example = "", required = true),
            @ApiImplicitParam(name = "customerSerialnumber", value = "客户编号", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "customerName", value = "客户名称", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "cycle", value = "统计周期（0日，1月，2季，3年）", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "date", value = "选择日期", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "payway", value = "支付方式（CASH，0，现金),(WEIXIN, 1, 微信)，(ALIPAY, 2, 支付宝)，(SYSTEM, 3, 系统)", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "paychannel", value = "收费渠道 (WUYE, 0, 物业),(APP, 1, 移动终端),(PLATFORM, 2, 费用核算)", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "areaId", value = "所属区域", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderColumn", value = "排序字段", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderType", value = "排序类型(asc,desc)", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/getChargeListPageVO")
    public ResponseEntity<PageVO<ChargeQueryPageVO>> getChargeListPageVO(
            @RequestParam(value = "chargeType",required = true)Integer chargeType,
            @RequestParam(value = "customerSerialnumber",required = false)String customerSerialnumber,
            @RequestParam(value = "customerName",required = false)String customerName,
            @RequestParam(value = "cycle",required = false)String cycle,
            @RequestParam(value = "date",required = false)String date,
            @RequestParam(value = "payway",required = false)Integer payway,
            @RequestParam(value = "paychannel",required = false)Integer paychannel,
            @RequestParam(value = "areaId",required = false)Integer areaId,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10")Integer pageSize,
            @RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum,
            @RequestParam(value = "orderColumn",required = false,defaultValue = "a.id") String orderColumn,
            @RequestParam(value = "orderType",required = false,defaultValue = "asc") String orderType
    ) {

        PageVO<ChargeQueryPageVO> pageVO = operationfeeChargeService.getChargeListPageVO(SystemConsts.ChargeType.getEnumByValue(chargeType),
                customerSerialnumber,customerName,cycle,date,
                areaId,payway,paychannel,pageSize,pageNum,orderColumn,orderType);
        return new ResponseEntity<>(pageVO);
    }

    @ApiOperation("客户费用记录分页列表-excel导出")
    @SystemLogRecordMonitor("客户费用记录分页列表-excel导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "chargeType", value = "费用类型 (缴费, 0),(退费, 1)", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "customerSerialnumber", value = "客户编号", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "customerName", value = "客户名称", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "cycle", value = "统计周期（0日，1月，2季，3年）", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "date", value = "选择日期", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "payway", value = "支付方式（CASH，0，现金),(WEIXIN, 1, 微信)，(ALIPAY, 2, 支付宝)，(SYSTEM, 3, 系统)", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "paychannel", value = "收费渠道 (WUYE, 0, 物业),(APP, 1, 移动终端),(PLATFORM, 2, 费用核算)", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "areaId", value = "所属区域", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderColumn", value = "排序字段", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "orderType", value = "排序类型(asc,desc)", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/exportChargeListExcel")
    public void exportChargeListExcel(
            @RequestParam(value = "chargeType",required = false)Integer chargeType,
            @RequestParam(value = "customerSerialnumber",required = false)String customerSerialnumber,
            @RequestParam(value = "customerName",required = false)String customerName,
            @RequestParam(value = "cycle",required = false)String cycle,
            @RequestParam(value = "date",required = false)String date,
            @RequestParam(value = "payway",required = false)Integer payway,
            @RequestParam(value = "paychannel",required = false)Integer paychannel,
            @RequestParam(value = "areaId",required = false)Integer areaId,
            @RequestParam(value = "orderColumn",required = false,defaultValue = "a.id") String orderColumn,
            @RequestParam(value = "orderType",required = false,defaultValue = "asc") String orderType
    ) {

        operationfeeChargeService.exportChargeListExcel(SystemConsts.ChargeType.getEnumByValue(chargeType),customerSerialnumber,customerName,cycle,date,
                areaId,payway,paychannel,orderColumn,orderType);
    }

    @ApiOperation("收费台账分页列表")
    @SystemLogRecordMonitor("收费台账分页列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cycle", value = "统计周期（0日，1月，2季，3年）", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "date", value = "选择日期", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "areaId", value = "所属区域", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/getChargeBookPageVO")
    public ResponseEntity<PageVO<ChargeBookPageVO>> getChargeBookPageVO(
            @RequestParam(value = "cycle",required = false)String cycle,
            @RequestParam(value = "date",required = false)String date,
            @RequestParam(value = "areaId",required = false)Integer areaId,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10")Integer pageSize,
            @RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum
    ) {

        PageVO<ChargeBookPageVO> pageVO = operationfeeChargeService.getChargeBookPageVO(cycle,date,
                areaId,pageSize,pageNum);
        return new ResponseEntity<>(pageVO);
    }

    @ApiOperation("收费台账分页列表-excel导出")
    @SystemLogRecordMonitor("收费台账分页列表-excel导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cycle", value = "统计周期（0日，1月，2季，3年）", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "date", value = "选择日期", dataType = "string", paramType = "query", example = "", required = false),
            @ApiImplicitParam(name = "areaId", value = "所属区域", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/exportChargeBookExcel")
    public void exportChargeBookExcel(
            @RequestParam(value = "cycle",required = false)String cycle,
            @RequestParam(value = "date",required = false)String date,
            @RequestParam(value = "areaId",required = false)Integer areaId
    ) {

        operationfeeChargeService.exportChargeBookExcel(cycle,date, areaId);
    }
}
